package ooday05;
/**
 * @author PXL
 * 枚举的演示
 */
public class EnumDemo {
    public static void main(String[] args) {
        Season s = Season.SUMMER;//获取SUMMER对象
        System.out.println(s);//SUMMER
        System.out.println(s.getSeasonName());//夏天
        System.out.println(s.getSeasonDesc());//炎热
        switch (s){
            case AUTUMN:
                System.out.println(s.getSeasonName()+",天气很"+s.getSeasonDesc()+"去睡觉");
                break;
            case SUMMER:
                System.out.println(s.getSeasonName()+"，天气很"+s.getSeasonDesc()+"去游泳");
                break;
            case SPRING:
                System.out.println(s.getSeasonName()+"，天气很"+s.getSeasonDesc()+"去赏花");
                break;
            case WINTER:
                System.out.println(s.getSeasonName()+"，天气很"+s.getSeasonDesc()+"去滑雪");
                break;
        }
        //获取所有枚举的对象
        Season[]seasons = Season.values();
        for(int i = 0;i<seasons.length;i++){
            //输出四个枚举对象
            System.out.println(seasons[i]);
            //输出枚举的名字
            System.out.println(seasons[i].getSeasonName());
            //输出枚举的描述属性
            System.out.println(seasons[i].getSeasonDesc());
        }
        Season o = Season.valueOf("SPRING");//获取春天对象,不常用
        System.out.println(o.getSeasonName()+","+o.getSeasonDesc());
    }
}
